﻿using Microsoft.Xna.Framework;

namespace Fighter.Screens
{
    /// <summary>
    /// Menu de pause dans le jeu
    /// </summary>
    class PauseMenuScreen : MenuScreen
    {
        #region Fields

        GraphicsDeviceManager graphics;
        Game game;

        #endregion

        #region Initialization

        /// <summary>
        /// Constructeur
        /// </summary>
        public PauseMenuScreen(Game game, GraphicsDeviceManager graphics)
            : base("Pause")
        {
            this.game = game;
            this.graphics = graphics;
            ScreenManagers.StateManager.CurrentScreenState = ScreenManagers.StateManager.ScreenState.Paused;
            // Création des entrées du menu
            MenuEntry resumeGameMenuEntry = new MenuEntry("Reprendre");
            MenuEntry optionGameMenuEntry = new MenuEntry("Options");
            MenuEntry quitGameMenuEntry = new MenuEntry("Quitter");

            // Ajout des évènements
            resumeGameMenuEntry.Selected += OnCancel;
            optionGameMenuEntry.Selected += OptionsMenuEntrySelected;
            quitGameMenuEntry.Selected += QuitGameMenuEntrySelected;

            // Ajout des entrées du menu
            MenuEntries.Add(resumeGameMenuEntry);
            MenuEntries.Add(optionGameMenuEntry);
            MenuEntries.Add(quitGameMenuEntry);
        }


        #endregion

        #region Handle Input

        /// <summary>
        /// Evènement lorsque l'option "Options" a été choisie
        /// </summary>
        void OptionsMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            ScreenManager.AddScreen(new OptionsMenuScreen(), e.PlayerIndex);
        }

        /// <summary>
        /// Evènement lorsque l'option "Quitter" a été choisie
        /// </summary>
        void QuitGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            ScreenManager.AddScreen(new BackToMainMenuScreen(game, graphics), e.PlayerIndex);
        }

        #endregion
    }
}
